
"""公告管理页面基类"""
from pages.base_page import BasePage
from selenium.webdriver.common.by import By

class  NoticeHomePage(BasePage):
    url='crm/index.php?m=announcement'
    #定位器
    #添加公告
    notice_add_locator = (By.CSS_SELECTOR, 'body > div.container > div.row > div:nth-child(1) > div.pull-right > a')
    #点击首页
    shouye_locator = (By.CSS_SELECTOR,'#form1 > table > tfoot > tr > td > div > div.span4 > div > ul > li:nth-child(1) > a')
    #最后一页
    zuihouyiye_locator = (By.CSS_SELECTOR, '#form1 > table > tfoot > tr > td > div > div.span4 > div > ul > li:nth-child(5) > a')
    #添加公告成功断言
    add_notice_success_locator = (By.CSS_SELECTOR,'body > div.container > div.alert.alert-success')
    #选择第一条公告
    xz_delete_locator = (By.CSS_SELECTOR, '#form1 > table > tbody > tr:nth-child(1) > td:nth-child(1) > input')
    #选择删除
    notice_delete_locator = (By.CSS_SELECTOR, '#delete')
    #删除成功断言
    notice_delete_success_locator = (By.XPATH,'/html/body/div[5]/div[2]')


    # 点击添加公告
    def click_add_notice(self):
        self.driver.find_element(*self.notice_add_locator).click()
    #点击首页
    def click_shouye_notice(self):
        self.driver.find_element(*self.shouye_locator).click()
    #点击最后一页
    def click_zuihouyiye_notice(self):
        self.driver.find_element(*self.zuihouyiye_locator).click()
    #选择第一条公告删除
    def check_first_notice(self):
        self.driver.find_element(*self.xz_delete_locator).click()
    #选择删除
    def click_delete_notice(self):
        self.driver.find_element(*self.notice_delete_locator).click()
        
    #获取最后url地址
    def get_last_url(self):
            return self.current_url()

    #公告添加成功断言
    def message_notice_add_success(self):
        message_notice = self.driver.find_element(*self.add_notice_success_locator).text
        return message_notice

    #公告删除成功断言
    def delete_notice_success(self):
        message_delete_notice = self.driver.find_element(*self.notice_delete_success_locator).text
        return message_delete_notice
